package com.example.register1.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.register1.domin.Load11;
import com.example.register1.exception.BusinessException;
import com.example.register1.result.ErrorResult;
import com.example.register1.result.Result;
import com.example.register1.service.LoadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/load")
public class LoadController {
    @Autowired
    private LoadService loadservice;
    @PostMapping("/add")
    public Result add(@RequestBody Load11 load){
        System.out.println(load);

        LambdaQueryWrapper<Load11> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        LambdaQueryWrapper<Load11> eq = lambdaQueryWrapper.eq(Load11::getPhone, load.getPhone());
        /*if(eq!=null){
          throw new BusinessException(ErrorResult.loginError());
        }*/
        try{
            loadservice.save(load);
            return  Result.success("注册成功");
        }catch(Exception e) {
            return  Result.error("该号码已被注册");
        }


    }


}
